package com.weiyun.wmzbasketscorecounter

import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel

class MainViewModel : ViewModel() {
    var aCount=MutableLiveData<Int>(0)
    var bCount=MutableLiveData<Int>(0)
    var aBack=0
    var bBack=0
    fun getATeamScore()=aCount
    fun getBTeamScore()=bCount

    fun addAScore(i:Int){
        aBack= aCount.value!!
        bBack= bCount.value!!
        aCount.value=aCount.value!!.plus(i)
    }

    fun addBScore(i:Int){
        aBack= aCount.value!!
        bBack= bCount.value!!
        bCount.value=bCount.value!!.plus(i)
    }
    fun reset(){
        aBack=aCount.value!!
        bBack=bCount.value!!
        aCount.value=0
        bCount.value=0
    }
    fun undo(){
        aCount.value=aBack
        bCount.value=bBack
    }
}